<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <style>
      table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        overflow-y: auto;
        margin: 0;
      }

      tr{
        margin: 0;
        padding: 0;
      }

      th,
      td {
        border: 1px solid black;
        padding: 5px;
        margin: 0;
      }

      .sticky {
        position: sticky;
        top: 0;
        background-color: skyblue;
        border-collapse: separate;
      }
      
      /* 解决间隙问题 */
      body {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <table>
      <tr class="sticky">
        <th>姓名</th>
        <th>学号</th>
        <th>成绩</th>
        <th>排名</th>
      </tr>

      <tr>
        <td>张三</td>
        <td>1001</td>
        <td>90</td>
        <td>1</td>
      </tr>

      <tr>
        <td>李四</td>
        <td>1002</td>
        <td>89</td>
        <td>2</td>
      </tr>

      <tr>
        <td>王五</td>
        <td>1003</td>
        <td>95</td>
        <td>3</td>
      </tr>

      <tr>
        <td>赵六</td>
        <td>1004</td>
        <td>88</td>
        <td>4</td>
      </tr>

      <tr>
        <td>孙七</td>
        <td>1005</td>
        <td>90</td>
        <td>5</td>
      </tr>

      <tr>
        <td>周八</td>
        <td>1006</td>
        <td>85</td>
        <td>6</td>
      </tr>

      <tr>
        <td>吴九</td>
        <td>1007</td>
        <td>95</td>
        <td>7</td>
      </tr>

      <tr>
        <td>郑十</td>
        <td>1008</td>
        <td>80</td>
        <td>8</td>
      </tr>

      <tr>
        <td>王十一</td>
        <td>1009</td>
        <td>90</td>
        <td>9</td>
      </tr>
    </table>
  </body>
</html>
